[XEND] Add some sort of rudimentary version embedding into the source
authorAlastair Tse <atse@xensource.com>
Thu, 12 Oct 2006 11:27:56 +0000 (12:27 +0100)
committerAlastair Tse <atse@xensource.com>
Thu, 12 Oct 2006 11:27:56 +0000 (12:27 +0100)
so we can report the Xend version number as opposed to Xen's version
number.

Signed-off-by: Alastair Tse <atse@xensource.com>
tools/python/setup.py
tools/python/xen/__init__.py
tools/python/xen/xend/XendNode.py
tools/python/xen/xend/server/SrvDaemon.py

index 640dcef0008953a01ce9c175514edf311569c3ed..f91571f62717fc4bb7d4cf5d47332c51f4ecf704 100644 (file)
@@ -1,7 +1,39 @@
+#!/usr/bin/python
 
 from distutils.core import setup, Extension
 import os
 
+XEN_TOOLS_VERSION = '3.0.4'
+
+def embed_version():
+    """ Embed Mercurial Changeset Version in xen/__init__.py. """
+    try:
+        import commands
+        import re
+        output = commands.getoutput('hg tip')
+        version = XEN_TOOLS_VERSION
+        changeset = ''
+        date = ''
+        if output:
+            for line in output.split('\n'):
+                is_changeset = re.search(r'^changeset:\s*(.*)$', line)
+                if is_changeset:
+                    changeset = is_changeset.group(1)
+                is_date = re.search(r'^date:\s*(.*)$', line)
+                if is_date:
+                    date = is_date.group(1)
+
+        xen_init = open('xen/__init__.py', 'w')
+        xen_init.write('# Warning, this file is autogenerated by setup.py\n')
+        if version and changeset and date:
+            xen_init.write('VERSION = "%s-%s (%s)"\n' %
+                           (version, changeset, date))
+        else:
+            xen_init.write('VERSION = "%s"\n' % version)
+        xen_init.close()
+    except:
+        print 'Warning: Unable to extract version.'
+
 XEN_ROOT = "../.."
 
 extra_compile_args  = [ "-fno-strict-aliasing", "-Wall", "-Werror" ]
@@ -38,8 +70,11 @@ acm = Extension("acm",
                libraries          = libraries,
                sources            = [ "xen/lowlevel/acm/acm.c" ])
 
+
+embed_version()
+
 setup(name            = 'xen',
-      version         = '3.0',
+      version         = XEN_TOOLS_VERSION,
       description     = 'Xen',
       packages        = ['xen',
                          'xen.lowlevel',
index 8d1c8b69c3fce7bea45c73efd06983e3c419a92f..7d86bd652d75413eb0457787b66f93b3605eb816 100644 (file)
@@ -1 +1,2 @@
+# Warning, this file is autogenerated by setup.py
+VERSION = "3.0.4-50:fa1d6b491cc5 (Fri Oct 06 22:50:29 2006 +0100)"
index 789c26cd9b43b6921a7d32c3107ea87f8e21d2ba..c02cad4e0731d273bef39117e67a62a9a4ab2bc8 100644 (file)
@@ -71,7 +71,9 @@ class XendNode:
 
     def xen_version(self):
         info = self.xc.xeninfo()
-        return {'Xen': '%(xen_major)d.%(xen_minor)d' % info}
+        from xen import VERSION
+        return {'Xen': '%(xen_major)d.%(xen_minor)d' % info,
+                'Xend': VERSION}
 
     def get_name(self):
         return self.name
index 845949a7567586c542d73b8a7617a807fc3bf5f0..65f042d1b51e8b9c039c29e9940bebaaa7dc4234 100644 (file)
@@ -289,6 +289,12 @@ class Daemon:
             log.info("Xend changeset: %s.", xinfo['xen_changeset'])
             del xc
 
+            try:
+                from xen import VERSION
+                log.info("Xend version: %s", VERSION)
+            except ImportError:
+                log.info("Xend version: Unknown.")
+
             relocate.listenRelocation()
             servers = SrvServer.create()
             servers.start(status)